class Vehicle < ActiveRecord::Base
	belongs_to :tour_group
	belongs_to :vehicle_model
	belongs_to :driver
	has_many :vehicle_rent_records, :dependent => :destroy
  
  def vehicle_rent_record_days=(days)
    
    self.vehicle_rent_records.destroy_all()
    
    for str in days
      is_use, d = str.split("|")
      self.vehicle_rent_records.build(:day => d) if is_use == "1"
    end
#    for o in self.vehicle_rent_records
#      puts o.inspect
#    end
#   1/0
  end
end
